package com.ruoyi.system.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.parameter.SystemPushText;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.UserSystemMsgMapper;
import com.ruoyi.system.domain.UserSystemMsg;
import com.ruoyi.system.service.IUserSystemMsgService;

/**
 * 用户系统推送消息Service业务层处理
 * 
 * @author DEREK
 * @date 2023-05-31
 */
@Service
public class UserSystemMsgServiceImpl extends ServiceImpl<UserSystemMsgMapper, UserSystemMsg> implements IUserSystemMsgService 
{
    @Autowired
    private UserSystemMsgMapper userSystemMsgMapper;

    /**
     * 查询用户系统推送消息
     * 
     * @param id 用户系统推送消息主键
     * @return 用户系统推送消息
     */
    @Override
    public UserSystemMsg selectUserSystemMsgById(Long id)
    {
        return userSystemMsgMapper.selectUserSystemMsgById(id);
    }

    /**
     * 查询用户系统推送消息列表
     * 
     * @param userSystemMsg 用户系统推送消息
     * @return 用户系统推送消息
     */
    @Override
    public List<UserSystemMsg> selectUserSystemMsgList(UserSystemMsg userSystemMsg)
    {
        return userSystemMsgMapper.selectUserSystemMsgList(userSystemMsg);
    }

    /**
     * 新增用户系统推送消息
     * 
     * @param userSystemMsg 用户系统推送消息
     * @return 结果
     */
    @Override
    public int insertUserSystemMsg(UserSystemMsg userSystemMsg)
    {
        userSystemMsg.setCreateTime(DateUtils.getNowDate());
        return userSystemMsgMapper.insertUserSystemMsg(userSystemMsg);
    }

    /**
     * 修改用户系统推送消息
     * 
     * @param userSystemMsg 用户系统推送消息
     * @return 结果
     */
    @Override
    public int updateUserSystemMsg(UserSystemMsg userSystemMsg)
    {
        return userSystemMsgMapper.updateUserSystemMsg(userSystemMsg);
    }

    /**
     * 批量删除用户系统推送消息
     * 
     * @param ids 需要删除的用户系统推送消息主键
     * @return 结果
     */
    @Override
    public int deleteUserSystemMsgByIds(Long[] ids)
    {
        return userSystemMsgMapper.deleteUserSystemMsgByIds(ids);
    }

    /**
     * 删除用户系统推送消息信息
     * 
     * @param id 用户系统推送消息主键
     * @return 结果
     */
    @Override
    public int deleteUserSystemMsgById(Long id)
    {
        return userSystemMsgMapper.deleteUserSystemMsgById(id);
    }

	@Override
	public void pushSystemMsg(Long userId, String title, String content) {
		UserSystemMsg userSystemMsg = new UserSystemMsg();
		userSystemMsg.setUserId(userId);
		userSystemMsg.setTitle(title);
		userSystemMsg.setContent(content);
		userSystemMsg.setIcon(SystemPushText.BDAppPushIcon.SYSTEM_ICON);
		this.save(userSystemMsg);
	}
}
